﻿
<%@ Page %>
<html>
<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312"/>
<title>Advanced View Properties</title>
<link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
<link rel="stylesheet" type="text/css" href="/_common/styles/dialogs.css">
<link rel="stylesheet" type="text/css" href="/_common/styles/select.css">

<script language="javascript" src="/_common/scripts/global.js"></script>
<script language="javascript" src="/Tools/ViewManager/Scripts/dialogs.js"></script>
<script language="javascript">

	function window.onload()
	{
		with (window.dialogArguments)
		{
			tdQueryType.innerHTML = "<span changeHandler='updateUI' name='queryType' class='selectBox' value='" + sQueryType + "'><table cellspacing='0' cellpadding='2' style='display: none;'><tr><td val='0'>Standard View</td></tr><tr><td val='1'>Advanced Find View</td></tr><tr><td val='2'>Associated View</td></tr></table></span>";

			queryApi.value		= sQueryApi;
			rootName.value		= sRootName;
			rowName.value		= sRowName;
			objectType.value	= sReturnTypeCode;
			idColumn.value		= sIdCol;

			if (sMultiObjId)
			{
				objIdColumn.value = sMultiObjId;
			}

			ckIcon.checked		= bGridIcon;
			ckPreview.checked	= bGridPreview;
			ckCheck.checked		= bGridCheck;
			ckCust.checked		= bViewCustomizable;
			ckQuickFind.checked	= bViewQuickFind;
			ckDefault.checked	= bViewDefault;

			// Handle Special Cases
			//
			queryApi.defaultValue = sQueryApi;
			
			if (queryApi.value == "")
			{
				rootName.value = "resultset";
				rowName.value = "result";
			}
			else
			{
				rootName.disabled = false;
				rowName.disabled = false;
			}
		}
	}


	function Ok()
	{
		if (objectType.value == "")
		{
			alert( "You must provide a Return Object Type Code." );
			objectType.focus();
			return false;
		}

		if (queryApi.value != "" && queryApi.value != queryApi.defaultValue)
		{
			if (!confirm( "You are attempting to make this view an API-based view. This will remove any previously configured Fetch XML.  Would you like to continue?" ))
			{
				return false;
			}
		}

		if (rootName.value == "")
		{
			if (confirm( "The Root XML Node name cannot be blank. Would you like to make the default \"resultset\"?" ))
			{
				rootName.value = "resultset";
			}
			else
			{
				return false;
			}
		}

		var o = new Object();
			o.sQueryApi			= queryApi.value;
			o.sRootName			= rootName.value;
			o.sRowName			= rowName.value;
			o.sQueryType		= queryType.returnValue;
			o.sIdCol			= idColumn.value;
			o.sReturnTypeCode	= objectType.value;
			o.sMultiObjId		= objIdColumn.value;
			o.bGridPreview		= ckPreview.checked;
			o.bGridIcon			= ckIcon.checked;
			o.bGridCheck		= ckCheck.checked;
			o.bViewCustomizable	= ckCust.checked;
			o.bViewQuickFind	= ckQuickFind.checked;
			o.bViewDefault		= ckDefault.checked;

		window.returnValue = o;
		window.close();
	}


	function updateUI()
	{
		rootName.disabled = (queryApi.value == "");
		rowName.disabled = rootName.disabled;

		// Validate Object Type Code
		//
		var i = parseInt(objectType.value, 10);
		objectType.value = (isNaN(i) ? "" : i);

		if (queryApi.value == "AUTO" || queryApi.value == "")
		{
			rootName.disabled = true;
			rowName.disabled = true;	

			if (queryApi.value == "AUTO")
			{
				rootName.value = "*";
				rowName.value = "*";
			}
			else
			{
				rootName.value = "resultset";
				rowName.value = "result";
			}
		}

		if (objectType.value != "" && idColumn.value != "")
		{
			btnDialogOk.disabled = false;
		}
	}
	
</script>

<style>

	div.secTitle
	{
		font-weight:bold;
		border-bottom:1px solid #999999;
		font-size: 11px;
		color:#222244;
	}

</style>

</head>
<body>

	<table border="0" cellspacing="0" cellpadding="8" width="100%" height="100%">
		<tr>
			<td class="header">
				<div class="header">Advanced View Properties</div>
				<div class="headerdesc">Caution: These settings are intended for expert use only.</div>
			</td>
		</tr>
		<tr>
			<td class="main">

				<table width="100%" cellspacing="0" cellpadding="4">
				<col width="135"><col>
					<tr>
						<td colspan="2"><div class="secTitle">General Properties</div></td>
					</tr>
					<tr height="20">
						<td>Query Type</td>
						<td id="tdQueryType"></td>
					</tr>
					<tr title="The Object Type Code that this View will display">
						<td>Return Object Type</td>
						<td><input type="text" name="objectType" onkeyup="updateUI();" maxlength="4"></td>
					</tr>
					<tr>
						<td colspan="2"><div class="secTitle" style="margin-top:10px;">Expert Properties</div></td>
					</tr>
					<tr title="The API name to use for this View. Type in 'AUTO' for Auto Mode support.">
						<td>Query API</td>
						<td><input type="text" name="queryApi" onkeyup="updateUI();" maxlength="100"></td>
					</tr>
					<tr title="This is the name of the root XML Node returned by the Platform, for Fetch based Views this would be 'resultset'">
						<td>Root XML Name</td>
						<td><input type="text" name="rootName" onkeyup="updateUI();" maxlength="50" disabled></td>
					</tr>
					<tr title="This is the name of the XML Node for each 'Row' in the result set returned by the Platform, for Fetch based Views this would be 'result'">
						<td>Row XML Name</td>
						<td><input type="text" name="rowName" onkeyup="updateUI();" maxlength="50" disabled></td>
					</tr>
					<tr title="This is the name of the field that the Grid will pass off when opening this object into a new window.">
						<td>GUID ID Column</td>
						<td><input type="text" name="idColumn" onkeyup="updateUI();" maxlength="50"></td>
					</tr>
					<tr title= "This is the name of the field that will provide the Object Type Code to bind to each row in the resultset. Current only Queues and Activities should require this.">
						<td>Multi-Object ID Column</td>
						<td><input type="text" name="objIdColumn" onkeyup="updateUI();" maxlength="50"></td>
					</tr>
				</table>

				<table cellpadding="0" width="100%" style="table-layout:fixed;margin-top:13px;">
				<col><col width="16"></col>
					<tr>
						<td valign="top">

							<div class="secTitle">Grid Configuration</div>

							<table width="100%" cellspacing="0" cellpadding="4" style="margin-left:10px;margin-top:10px;">
							<col width="20"><col>
								<tr>
									<td><input type="checkbox" class="checkbox" onclick="updateUI();" id="ckIcon"></td>
									<td><label for="ckIcon">Show Icon</label></td>
								</tr>
								<tr>
									<td><input type="checkbox" class="checkbox" onclick="updateUI();" id="ckPreview"></td>
									<td><label for="ckPreview">Show Preview</label></td>
								</tr>
								<tr>
									<td><input type="checkbox" class="checkbox" onclick="updateUI();" id="ckCheck"></td>
									<td><label for="ckCheck">Show Check Box</label></td>
								</tr>
							</table>

						</td>
						<td>&nbsp;</td>
						<td valign="top">
							<div class="secTitle">View Configuration</div>

							<table width="100%" cellspacing="0" cellpadding="4" style="margin-left:10px;margin-top:10px;">
							<col width="20"><col>
								<tr>
									<td><input type="checkbox" class="checkbox" onclick="updateUI();" id="ckCust"></td>
									<td><label for="ckCust">Customizable</label></td>
								</tr>
								<tr>
									<td><input type="checkbox" class="checkbox" onclick="updateUI();" id="ckQuickFind"></td>
									<td><label for="ckQuickFind">Quick Find Compatible</label></td>
								</tr>
								<tr>
									<td><input type="checkbox" class="checkbox" onclick="updateUI();" id="ckDefault"></td>
									<td><label for="ckDefault">Is Default View</label></td>
								</tr>
							</table>
						
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td class="buttons">
				<button id="btnDialogOk" onclick="Ok();" disabled>OK</button>
				&nbsp;
				<button onclick="window.close();">Cancel</button>
			</td>
		</tr>
	</table>

</body>
</html>
